package com.yaya.spring.db.jdbc;

import com.yaya.spring.db.AccountDao;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JdbcDao implements AccountDao {

    private DataSource dataSource;

    public DataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public void update(int accountId, int balance) {
           try{
               Connection conn = dataSource.getConnection();
               Statement st = conn.createStatement();
               String sql = "select * from insys_user_info";
               ResultSet rs = st.executeQuery(sql);
               while(rs.next()){
                   String name = rs.getString("USER_NAME");
                   System.out.println(name);
               }
               System.out.println(conn);
               conn.close();
           }catch (Exception e){
               e.printStackTrace();
           }
    }

}
